package org.example.everyday;

/**
 * <p>
 * Description:TODO 详细描述
 * <p>
 * <p>
 *
 * @author anlu
 * @date 2022/5/9 11:00
 */
public class Lc942 {
    public static void main(String[] args) {
        Lc942 lc942 = new Lc942();
        int[] res = lc942.diStringMatch("IDID");
        System.out.println(res);

    }

    public int[] diStringMatch(String s) {
        int n = s.length(),lo = 0,hi = n;
        int[] perm = new int[n + 1];
        for (int i = 0; i < n; i++) {
            perm[i] = s.charAt(i) == 'I' ? lo++ : hi--;

        }
        //最后剩下一个数时，此时lo = hi
        perm[n] = lo;
        return perm;
    }
}
